package com.liranhui.blocks;

import java.util.ArrayList;

import com.liranhui.mod.RanhuiMod;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistry;

public class ModBlocksRegister {

    private ArrayList<Block>        _blocks;
    private ArrayList<BlockItem>    _blockItems;

    public ModBlocksRegister() {
        Block block = new Block(BlockBehaviour.Properties.of(Material.METAL).strength(12.f));
        block.setRegistryName(RanhuiMod.ModID, "energy");
        BlockItem blockItem = new BlockItem(block, new Item.Properties().tab(CreativeModeTab.TAB_MISC));
        blockItem.setRegistryName(RanhuiMod.ModID, "energy");
        _blocks = new ArrayList<Block>();
        _blockItems = new ArrayList<BlockItem>();
        _blocks.add(block);
        _blockItems.add(blockItem);
    }

    @SubscribeEvent
    public void registerBlocks(RegistryEvent.Register<Block> event) {
        for( int i = 0; i < _blocks.size(); ++i) {
            event.getRegistry().register(_blocks.get(i));
        }
    }

    public void registBlockItems( IForgeRegistry<Item> registry ) {
        for( int i = 0; i < _blockItems.size(); ++i) {
            registry.register(_blockItems.get(i));
        }
    }
}
